<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>后台管理</title>
  <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
</head>
<style>
</style>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo layui-hide-xs layui-bg-black">管理系统</div>
    <!-- 头部区域（可配合layui 已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <!-- 移动端显示 -->
<!--      <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">-->
<!--        <i class="layui-icon layui-icon-spread-left"></i>-->
<!--      </li>-->

      <!--      <li class="layui-nav-item layui-hide-xs"><a href="">nav 1</a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="">nav 2</a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="">nav 3</a></li>
            <li class="layui-nav-item">
              <a href="javascript:;">nav groups</a>
              <dl class="layui-nav-child">
                <dd><a href="">menu 11</a></dd>
                <dd><a href="">menu 22</a></dd>
                <dd><a href="">menu 33</a></dd>
              </dl>
            </li> -->
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item layui-hide layui-show-md-inline-block">
        <a href="javascript:;">
          <i class="layui-icon layui-icon-username"></i>
          [[${user.getUsername()}]]
        </a>
        <dl class="layui-nav-child">
<!--          <dd><a href="">个人信息</a></dd>-->
<!--          <dd><a href="">设置</a></dd>-->
          <dd click-event="logout"><a>退出</a></dd>
        </dl>
      </li>
    </ul>
  </div>

  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree" lay-filter="test">
        <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">人员管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">人员列表</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">咨询管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">咨询列表</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item"><a href="javascript:;">click menu item</a></li>
        <li class="layui-nav-item"><a href="">the links</a></li>
      </ul>
    </div>
  </div>

  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div th:if="${user != null && user.getRole().equals('ROLE_ADMIN')}" style="padding: 15px;">内容主体区域。记得修改 layui.css 和 js 的路径</div>
    <div th:if="${user == null || !user.getRole().equals('ROLE_ADMIN')}" style="padding: 15px; color: #FF5722; font-size: 40px; text-align: center">没有权限，找管理员添加权限</div>
  </div>

  <div class="layui-footer">
    <!-- 底部固定区域 -->
    底部固定区域
  </div>
</div>
<script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
  <script>
    //JS
    layui.use(['element', 'layer', 'util'], function(){
    var element = layui.element,layer = layui.layer,util = layui.util,$ = layui.$;

    //头部事件
    util.event('click-event',{//左侧菜单事件
      logout: function(){
        $.ajax({
          type: "POST", url: "/logout", dataType: "json", success: function (data) {
            console.log(data.code);
            if (data.code > 0) {
              alert(data.message);
            } else {
              location.href = "/adminfront/login";
            }
          }
        });
      }
    });
  });
</script>
</body>
</html>